package za.ac.cput.arrowgame.presentation.desktop.message;

import javax.swing.JOptionPane;
import javax.swing.JRootPane;
import org.springframework.stereotype.Component;

@Component("userMessageService")
public class UserMessageServiceImpl implements UserMessageService {

    protected UserMessageServiceImpl() {
    }

    public Integer showStartNewGameMessage(JRootPane rootPane) {
        Integer gridSize = 0;
        String[] selectionValues = {"6", "9", "12"};
        String size = (String) JOptionPane.showInputDialog(rootPane, "Select your grid size:", "Grid Size", JOptionPane.QUESTION_MESSAGE, null, selectionValues, "9");
        if (size != null) {
            gridSize = Integer.valueOf(size);
        }
        return gridSize;
    }

    public void showMessageDialog(JRootPane rootPane, String message) {
        JOptionPane.showMessageDialog(rootPane, message, "Message", JOptionPane.INFORMATION_MESSAGE);
    }

    public void showErrorDialog(JRootPane rootPane, String message) {
        JOptionPane.showMessageDialog(rootPane, message, "Error", JOptionPane.ERROR_MESSAGE);
    }
}
